import exporter.RpcExporter;
import importer.RpcImporter;
import provider.EchoService;
import provider.EchoServiceImpl;
import register.MapRegister;

import java.net.InetSocketAddress;

public class RpcTest {
    public static void main(String[] args) {
        MapRegister.register(EchoService.class.getName(), EchoServiceImpl.class);
        new Thread(() -> {
            try {
                RpcExporter.exporter("localhost", 9090);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();

        RpcImporter<EchoService> importer = new RpcImporter<>();
        EchoService echoService = importer.importer(EchoService.class, new InetSocketAddress("localhost", 9090));
        System.out.println(echoService.echo("Are you Ok ?"));
    }
}
